package com.ftg.learn.day07;


import java.util.Arrays;
import java.util.Map;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;

/**
 * 学习string02
 *
 * @author 布衣
 */
public class String02 extends Object {

    public static void main(String[] args) {
        String str = "abc";
        String str1 = "abc";

        String str2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

        String words = "fjdskajflkjavalfdjsaklfjdslkafjskljava老大哥垃圾分类java里奇jfdsadjavaldfjslkafd";
        String reg1 = ".*ja1va.*";

        int sum = 0;
        int n = 0;
        while ((n = words.indexOf("java", n)) != -1) {
            sum++;
            n+="java".length();
        }
        System.out.println(sum);


        System.out.println("abc".substring(2));

        System.out.println("tttaatt".replace("t", "a"));
        String tel = "15326619037";
        System.out.println(tel.replace(tel.substring(3, 7), "****"));

        String a ="ok";
        for(int i = 0,len=a.length();i < len;i++){
            a+= a.charAt(len-1-i);
        }

        System.out.println(a+"--->");

        System.out.println(a.toUpperCase());

        System.out.println("张三丰".startsWith("张"));
        System.out.println("张三丰".endsWith("张"));

        String s = "1009-9-9";
        String[] split = s.split("-");
        System.out.println(Arrays.toString(split));

        //正则表达式

        //指一段特定的由0-9a-z
//        []取值范围
//        {}长度范围
//        ()
//        \w{6,8}
//        (a.b)[a.b]
//        【^0-9a-zA-Z】
//        [0-9] \d {0,1} ?
//        [0-9]? [0-9]{0,1} \d? [0-9]{1,} \d+ \d* 【0-9】{0，}
        //电话号码正则表达式
        String reg = "(045)[1-9]-[1-9][0-9]{7}";
        System.out.println("0459-12367132".matches(reg));
        System.out.println("0459-02367132".matches(reg));
        System.out.println("0559-02367132".matches(reg));

        //可变字符序列
        String abc ="a"+"b"+"c";
        StringBuilder stringBuilder = new StringBuilder("abc");
        //19
        //19 + 1 << 1+ 2
        //链式调用
        stringBuilder.append("d").append("d").reverse();
        stringBuilder.insert(1,"d");
        stringBuilder.delete(1,2);
        stringBuilder.setCharAt(0,'x');
        stringBuilder.setLength(0);

        StringBuffer sb = new StringBuffer();
        // synchronized
        //28 3 499
    }


}
